home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / dlibsrc.arc / RAND.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-09  |  488 b   |  27 lines

  1. #include <osbind.h>
  2. #include <stdio.h>
  3.  
  4. rand()
  5.     {
  6.     return((Random() >> 3) & RAND_MAX);
  7.     }
  8.  
  9. /*
  10.  *    In environments where the operating system doesn't provide
  11.  *    a random number generator, the following code may be useful.
  12.  *
  13.  *    static unsigned long _seed = 1;
  14.  *
  15.  *    int rand()
  16.  *        {
  17.  *        _seed = (_seed * 1103515245) + 12345;
  18.  *        return((unsigned int) ((next / 65536) % 32768));
  19.  *        }
  20.  *
  21.  *    void srand(seed)
  22.  *        unsigned int seed;
  23.  *        {
  24.  *        _seed = seed;
  25.  *        }
  26.  */
  27.